package com.ruoyi.houses.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.houses.domain.AtbPropertyInformation;
import com.ruoyi.houses.service.IAtbPropertyInformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物业信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-16
 */
@RestController
@RequestMapping("/houses/information")
public class AtbPropertyInformationController extends BaseController
{
    @Autowired
    private IAtbPropertyInformationService atbPropertyInformationService;

    /**
     * 查询物业信息列表
     */
    @PreAuthorize("@ss.hasPermi('houses:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(AtbPropertyInformation atbPropertyInformation)
    {
        startPage();
        List<AtbPropertyInformation> list = atbPropertyInformationService.selectAtbPropertyInformationList(atbPropertyInformation);
        return getDataTable(list);
    }

    /**
     * 导出物业信息列表
     */
    @PreAuthorize("@ss.hasPermi('houses:information:export')")
    @Log(title = "物业信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AtbPropertyInformation atbPropertyInformation)
    {
        List<AtbPropertyInformation> list = atbPropertyInformationService.selectAtbPropertyInformationList(atbPropertyInformation);
        ExcelUtil<AtbPropertyInformation> util = new ExcelUtil<AtbPropertyInformation>(AtbPropertyInformation.class);
        util.exportExcel(response, list, "物业信息数据");
    }

    /**
     * 获取物业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('houses:information:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(atbPropertyInformationService.selectAtbPropertyInformationById(id));
    }

    /**
     * 新增物业信息
     */
    @PreAuthorize("@ss.hasPermi('houses:information:add')")
    @Log(title = "物业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AtbPropertyInformation atbPropertyInformation)
    {
        return toAjax(atbPropertyInformationService.insertAtbPropertyInformation(atbPropertyInformation));
    }

    /**
     * 修改物业信息
     */
    @PreAuthorize("@ss.hasPermi('houses:information:edit')")
    @Log(title = "物业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AtbPropertyInformation atbPropertyInformation)
    {
        return toAjax(atbPropertyInformationService.updateAtbPropertyInformation(atbPropertyInformation));
    }

    /**
     * 删除物业信息
     */
    @PreAuthorize("@ss.hasPermi('houses:information:remove')")
    @Log(title = "物业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(atbPropertyInformationService.deleteAtbPropertyInformationByIds(ids));
    }
}
